package com.cgtong.android.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.zhouyou.http.model.ApiResult;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * Created by chunc on 2017/10/23.
 */

public class ProblemBean extends ApiResult implements Parcelable, Cloneable {


    /**
     * id : 1
     * createUserId : 1
     * createTime : 2016-02-03 12:23:22
     * reportTime : 2016-02-03 12:23:22
     * status : 1
     * catagoryId : 0
     * address : aa
     * isOpen : 1
     * reviewLevel : 0
     * isExpired : 2
     * desc : aaa
     * lng : 10.23
     * lat : 23.32
     * voiceUrl : xxxxx.wmv
     * localImgUrl : xxxxx.jpg
     * resourceList : [{"id":1,"content":"ssdsd.jpg","bossId":1}]
     * problemLevel : 0
     * isAttention : 1
     * isCreateUserAttention : 1
     * statusChangeList : null
     * isDraft : 0
     * nickName : aaa
     * dn : 12313231313
     */

    private long id;
    public int createUserId;
    private String createTime;
    private String reportTime;
    private int status;
    private long catagoryId;
    private String address;
    private int isOpen;
    private int reviewLevel;//评价，1，很满意，2，满意，3，普通，4不满意
    private int isExpired;//1:超期 2:未超期
    private String desc;
    private double lng;
    private double lat;
    private String voiceUrl;
    private int voiceTime;
    private String localImgUrl;
    private int problemLevel;
    public int isAttention;//是否关注了该问题，1关注，0未关注
    public int isCreateUserAttention;//是否关注了该问题提出人，1关注，0未关注
    private int isDraft;//是否草稿，0不是，1是
    private String nickName;
    private String dn;
    private int avasterId;
    private List<ResourceBean> resourceList;
    private List<StatusChangeBean> statusChangeList;
    private List<PushImageBean> pushImgList;

    public ProblemBean cloneAll(ProblemBean m) {
        ProblemBean problemBean = m.clone();
        //=======================================
        List<ResourceBean> resourceList = problemBean.resourceList;
        if (resourceList != null && resourceList.size() > 0) {
            List<ResourceBean> colneResourceList = new ArrayList<>();
            Iterator<ResourceBean> prizeBeanIterator = resourceList.iterator();
            while (prizeBeanIterator.hasNext()) {
                colneResourceList.add(prizeBeanIterator.next().clone());
            }
            problemBean.resourceList = colneResourceList;
        }
        //=============================================
        List<StatusChangeBean> statusChangeList = problemBean.statusChangeList;
        if (statusChangeList != null && statusChangeList.size() > 0) {
            List<StatusChangeBean> cloneStatusChangeList = new ArrayList<>();
            Iterator<StatusChangeBean> commentBeanIterator = statusChangeList.iterator();
            while (commentBeanIterator.hasNext()) {
                cloneStatusChangeList.add(commentBeanIterator.next().clone());
            }
            problemBean.statusChangeList = cloneStatusChangeList;
        }
        return problemBean;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ProblemBean bean = (ProblemBean) o;

        if (id != bean.id) return false;
        if (createUserId != bean.createUserId) return false;
        if (status != bean.status) return false;
        if (catagoryId != bean.catagoryId) return false;
        if (isOpen != bean.isOpen) return false;
        if (reviewLevel != bean.reviewLevel) return false;
        if (isExpired != bean.isExpired) return false;
        if (Double.compare(bean.lng, lng) != 0) return false;
        if (Double.compare(bean.lat, lat) != 0) return false;
        if (voiceTime != bean.voiceTime) return false;
        if (problemLevel != bean.problemLevel) return false;
        if (isAttention != bean.isAttention) return false;
        if (isCreateUserAttention != bean.isCreateUserAttention) return false;
        if (isDraft != bean.isDraft) return false;
        if (avasterId != bean.avasterId) return false;
        if (createTime != null ? !createTime.equals(bean.createTime) : bean.createTime != null)
            return false;
        if (reportTime != null ? !reportTime.equals(bean.reportTime) : bean.reportTime != null)
            return false;
        if (address != null ? !address.equals(bean.address) : bean.address != null) return false;
        if (desc != null ? !desc.equals(bean.desc) : bean.desc != null) return false;
        if (voiceUrl != null ? !voiceUrl.equals(bean.voiceUrl) : bean.voiceUrl != null)
            return false;
        if (localImgUrl != null ? !localImgUrl.equals(bean.localImgUrl) : bean.localImgUrl != null)
            return false;
        if (nickName != null ? !nickName.equals(bean.nickName) : bean.nickName != null)
            return false;
        if (dn != null ? !dn.equals(bean.dn) : bean.dn != null) return false;
        if (resourceList != null ? !resourceList.equals(bean.resourceList) : bean.resourceList != null)
            return false;
        if (statusChangeList != null ? !statusChangeList.equals(bean.statusChangeList) : bean.statusChangeList != null)
            return false;
        return pushImgList != null ? pushImgList.equals(bean.pushImgList) : bean.pushImgList == null;

    }

    @Override
    public int hashCode() {
        int result;
        long temp;
        result = (int) (id ^ (id >>> 32));
        result = 31 * result + createUserId;
        result = 31 * result + (createTime != null ? createTime.hashCode() : 0);
        result = 31 * result + (reportTime != null ? reportTime.hashCode() : 0);
        result = 31 * result + status;
        result = 31 * result + (int) (catagoryId ^ (catagoryId >>> 32));
        result = 31 * result + (address != null ? address.hashCode() : 0);
        result = 31 * result + isOpen;
        result = 31 * result + reviewLevel;
        result = 31 * result + isExpired;
        result = 31 * result + (desc != null ? desc.hashCode() : 0);
        temp = Double.doubleToLongBits(lng);
        result = 31 * result + (int) (temp ^ (temp >>> 32));
        temp = Double.doubleToLongBits(lat);
        result = 31 * result + (int) (temp ^ (temp >>> 32));
        result = 31 * result + (voiceUrl != null ? voiceUrl.hashCode() : 0);
        result = 31 * result + voiceTime;
        result = 31 * result + (localImgUrl != null ? localImgUrl.hashCode() : 0);
        result = 31 * result + problemLevel;
        result = 31 * result + isAttention;
        result = 31 * result + isCreateUserAttention;
        result = 31 * result + isDraft;
        result = 31 * result + (nickName != null ? nickName.hashCode() : 0);
        result = 31 * result + (dn != null ? dn.hashCode() : 0);
        result = 31 * result + avasterId;
        result = 31 * result + (resourceList != null ? resourceList.hashCode() : 0);
        result = 31 * result + (statusChangeList != null ? statusChangeList.hashCode() : 0);
        result = 31 * result + (pushImgList != null ? pushImgList.hashCode() : 0);
        return result;
    }

    @Override
    protected ProblemBean clone() {
        ProblemBean problemBean = null;
        try {
            problemBean = (ProblemBean) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return problemBean;
    }

    public int getVoiceTime() {
        return voiceTime;
    }

    public void setVoiceTime(int voiceTime) {
        this.voiceTime = voiceTime;
    }

    public void setPushImgList(List<PushImageBean> pushImgList) {
        this.pushImgList = pushImgList;
    }

    public List<PushImageBean> getPushImgList() {
        return pushImgList;
    }

    public int getAvasterId() {
        return avasterId;
    }

    public void setAvasterId(int avasterId) {
        this.avasterId = avasterId;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public int getCreateUserId() {
        return createUserId;
    }

    public void setCreateUserId(int createUserId) {
        this.createUserId = createUserId;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getReportTime() {
        return reportTime;
    }

    public void setReportTime(String reportTime) {
        this.reportTime = reportTime;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public long getCatagoryId() {
        return catagoryId;
    }

    public void setCatagoryId(long catagoryId) {
        this.catagoryId = catagoryId;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public int getIsOpen() {
        return isOpen;
    }

    public void setIsOpen(int isOpen) {
        this.isOpen = isOpen;
    }

    public int getReviewLevel() {
        return reviewLevel;
    }

    public void setReviewLevel(int reviewLevel) {
        this.reviewLevel = reviewLevel;
    }

    public int getIsExpired() {
        return isExpired;
    }

    public void setIsExpired(int isExpired) {
        this.isExpired = isExpired;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public double getLng() {
        return lng;
    }

    public void setLng(double lng) {
        this.lng = lng;
    }

    public double getLat() {
        return lat;
    }

    public void setLat(double lat) {
        this.lat = lat;
    }

    public String getVoiceUrl() {
        return voiceUrl;
    }

    public void setVoiceUrl(String voiceUrl) {
        this.voiceUrl = voiceUrl;
    }

    public String getLocalImgUrl() {
        return localImgUrl;
    }

    public void setLocalImgUrl(String localImgUrl) {
        this.localImgUrl = localImgUrl;
    }

    public int getProblemLevel() {
        return problemLevel;
    }

    public void setProblemLevel(int problemLevel) {
        this.problemLevel = problemLevel;
    }

    public int getIsAttention() {
        return isAttention;
    }

    public void setIsAttention(int isAttention) {
        this.isAttention = isAttention;
    }

    public int getIsCreateUserAttention() {
        return isCreateUserAttention;
    }

    public void setIsCreateUserAttention(int isCreateUserAttention) {
        this.isCreateUserAttention = isCreateUserAttention;
    }

    public int getIsDraft() {
        return isDraft;
    }

    public void setIsDraft(int isDraft) {
        this.isDraft = isDraft;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public String getDn() {
        return dn;
    }

    public void setDn(String dn) {
        this.dn = dn;
    }

    public List<ResourceBean> getResourceList() {
        return resourceList;
    }

    public void setResourceList(List<ResourceBean> resourceList) {
        this.resourceList = resourceList;
    }

    public List<StatusChangeBean> getStatusChangeList() {
        return statusChangeList;
    }

    public void setStatusChangeList(List<StatusChangeBean> statusChangeList) {
        this.statusChangeList = statusChangeList;
    }

    @Override
    public String toString() {
        return "ProblemBean{" +
                "id=" + id +
                ", createUserId=" + createUserId +
                ", createTime='" + createTime + '\'' +
                ", reportTime='" + reportTime + '\'' +
                ", status=" + status +
                ", catagoryId=" + catagoryId +
                ", address='" + address + '\'' +
                ", isOpen=" + isOpen +
                ", reviewLevel=" + reviewLevel +
                ", isExpired=" + isExpired +
                ", desc='" + desc + '\'' +
                ", lng=" + lng +
                ", lat=" + lat +
                ", voiceUrl='" + voiceUrl + '\'' +
                ", voiceTime=" + voiceTime +
                ", localImgUrl='" + localImgUrl + '\'' +
                ", problemLevel=" + problemLevel +
                ", isAttention=" + isAttention +
                ", isCreateUserAttention=" + isCreateUserAttention +
                ", isDraft=" + isDraft +
                ", nickName='" + nickName + '\'' +
                ", dn='" + dn + '\'' +
                ", avasterId=" + avasterId +
                ", resourceList=" + resourceList +
                ", statusChangeList=" + statusChangeList +
                ", pushImgList=" + pushImgList +
                '}';
    }

    public static class PushImageBean implements Parcelable, Cloneable {
        private long problemId;
        private long userId;
        private String picName;

        public long getProblemId() {
            return problemId;
        }

        public long getUserId() {
            return userId;
        }

        public String getPicName() {
            return picName;
        }

        @Override
        protected PushImageBean clone() {
            PushImageBean pushImageBean = null;
            try {
                pushImageBean = (PushImageBean) super.clone();
            } catch (CloneNotSupportedException e) {
                e.printStackTrace();
            }
            return pushImageBean;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;

            PushImageBean that = (PushImageBean) o;

            if (problemId != that.problemId) return false;
            if (userId != that.userId) return false;
            return picName != null ? picName.equals(that.picName) : that.picName == null;

        }

        @Override
        public int hashCode() {
            int result = (int) (problemId ^ (problemId >>> 32));
            result = 31 * result + (int) (userId ^ (userId >>> 32));
            result = 31 * result + (picName != null ? picName.hashCode() : 0);
            return result;
        }

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeLong(this.problemId);
            dest.writeLong(this.userId);
            dest.writeString(this.picName);
        }

        public PushImageBean() {
        }

        protected PushImageBean(Parcel in) {
            this.problemId = in.readLong();
            this.userId = in.readLong();
            this.picName = in.readString();
        }

        public static final Creator<PushImageBean> CREATOR = new Creator<PushImageBean>() {
            @Override
            public PushImageBean createFromParcel(Parcel source) {
                return new PushImageBean(source);
            }

            @Override
            public PushImageBean[] newArray(int size) {
                return new PushImageBean[size];
            }
        };
    }

    public static class ResourceBean implements Parcelable, Cloneable {
        /**
         * id : 1
         * content : ssdsd.jpg
         * bossId : 1
         */

        private long id;
        private String content;
        private String smallContent;
        private String bigContent;
        private long bossId;


        public String getBigContent() {
            return bigContent;
        }

        public void setBigContent(String bigContent) {
            this.bigContent = bigContent;
        }

        public String getSmallContent() {
            return smallContent;
        }

        public void setSmallContent(String smallContent) {
            this.smallContent = smallContent;
        }

        public long getId() {
            return id;
        }

        public void setId(long id) {
            this.id = id;
        }

        public String getContent() {
            return content;
        }

        public void setContent(String content) {
            this.content = content;
        }

        public long getBossId() {
            return bossId;
        }

        public void setBossId(long bossId) {
            this.bossId = bossId;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;

            ResourceBean that = (ResourceBean) o;

            if (id != that.id) return false;
            if (bossId != that.bossId) return false;
            if (content != null ? !content.equals(that.content) : that.content != null)
                return false;
            if (smallContent != null ? smallContent.equals(that.smallContent) : that.smallContent == null)
                return false;
            return bigContent != null ? bigContent.equals(that.bigContent) : that.bigContent == null;

        }

        @Override
        public int hashCode() {
            int result = (int) (id ^ (id >>> 32));
            result = 31 * result + (content != null ? content.hashCode() : 0);
            result = 31 * result + (smallContent != null ? smallContent.hashCode() : 0);
            result = 31 * result + (bigContent != null ? bigContent.hashCode() : 0);
            result = 31 * result + (int) (bossId ^ (bossId >>> 32));
            return result;
        }

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        protected ResourceBean clone() {
            ResourceBean resourceBean = null;
            try {
                resourceBean = (ResourceBean) super.clone();
            } catch (CloneNotSupportedException e) {
                e.printStackTrace();
            }
            return resourceBean;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeLong(this.id);
            dest.writeString(this.content);
            dest.writeString(this.smallContent);
            dest.writeString(this.bigContent);
            dest.writeLong(this.bossId);
        }

        public ResourceBean() {
        }

        public ResourceBean(String content) {
            this.content = content;
        }

        protected ResourceBean(Parcel in) {
            this.id = in.readLong();
            this.content = in.readString();
            this.smallContent = in.readString();
            this.bigContent = in.readString();
            this.bossId = in.readLong();
        }

        public static final Creator<ResourceBean> CREATOR = new Creator<ResourceBean>() {
            @Override
            public ResourceBean createFromParcel(Parcel source) {
                return new ResourceBean(source);
            }

            @Override
            public ResourceBean[] newArray(int size) {
                return new ResourceBean[size];
            }
        };
    }

    public static class StatusChangeBean implements Parcelable, Cloneable {


        /**
         * id : 1
         * problemId : 1
         * status : 2
         * desc : aaa
         * createTime : 2017-08-09 12:21:33
         * deptName : aaa
         * imgUrl : http://a.jpg
         */


        private long id;
        private long problemId;
        private int status;
        private String desc;
        private String createTime;
        private String deptName;
        private String imgUrl;

        @Override
        protected StatusChangeBean clone() {
            StatusChangeBean statusChangeBean = null;
            try {
                statusChangeBean = (StatusChangeBean) super.clone();
            } catch (CloneNotSupportedException e) {
                e.printStackTrace();
            }
            return statusChangeBean;
        }

        public long getId() {
            return id;
        }

        public void setId(long id) {
            this.id = id;
        }

        public long getProblemId() {
            return problemId;
        }

        public void setProblemId(long problemId) {
            this.problemId = problemId;
        }

        public int getStatus() {
            return status;
        }

        public void setStatus(int status) {
            this.status = status;
        }

        public String getDesc() {
            return desc;
        }

        public void setDesc(String desc) {
            this.desc = desc;
        }

        public String getCreateTime() {
            return createTime;
        }

        public void setCreateTime(String createTime) {
            this.createTime = createTime;
        }

        public String getDeptName() {
            return deptName;
        }

        public void setDeptName(String deptName) {
            this.deptName = deptName;
        }

        public String getImgUrl() {
            return imgUrl;
        }

        public void setImgUrl(String imgUrl) {
            this.imgUrl = imgUrl;
        }

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeLong(this.id);
            dest.writeLong(this.problemId);
            dest.writeInt(this.status);
            dest.writeString(this.desc);
            dest.writeString(this.createTime);
            dest.writeString(this.deptName);
            dest.writeString(this.imgUrl);
        }

        public StatusChangeBean() {
        }

        protected StatusChangeBean(Parcel in) {
            this.id = in.readLong();
            this.problemId = in.readLong();
            this.status = in.readInt();
            this.desc = in.readString();
            this.createTime = in.readString();
            this.deptName = in.readString();
            this.imgUrl = in.readString();
        }

        public static final Creator<StatusChangeBean> CREATOR = new Creator<StatusChangeBean>() {
            @Override
            public StatusChangeBean createFromParcel(Parcel source) {
                return new StatusChangeBean(source);
            }

            @Override
            public StatusChangeBean[] newArray(int size) {
                return new StatusChangeBean[size];
            }
        };
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(this.id);
        dest.writeInt(this.createUserId);
        dest.writeString(this.createTime);
        dest.writeString(this.reportTime);
        dest.writeInt(this.status);
        dest.writeLong(this.catagoryId);
        dest.writeString(this.address);
        dest.writeInt(this.isOpen);
        dest.writeInt(this.reviewLevel);
        dest.writeInt(this.isExpired);
        dest.writeString(this.desc);
        dest.writeDouble(this.lng);
        dest.writeDouble(this.lat);
        dest.writeString(this.voiceUrl);
        dest.writeInt(this.voiceTime);
        dest.writeString(this.localImgUrl);
        dest.writeInt(this.problemLevel);
        dest.writeInt(this.isAttention);
        dest.writeInt(this.isCreateUserAttention);
        dest.writeInt(this.isDraft);
        dest.writeString(this.nickName);
        dest.writeString(this.dn);
        dest.writeInt(this.avasterId);
        dest.writeTypedList(this.resourceList);
        dest.writeList(this.statusChangeList);
    }

    public ProblemBean() {
    }

    public ProblemBean(long id) {
        this.id = id;
    }

    public ProblemBean(int status, int isExpired, double lng, double lat) {
        this.status = status;
        this.isExpired = isExpired;
        this.lng = lng;
        this.lat = lat;
    }

    protected ProblemBean(Parcel in) {
        this.id = in.readLong();
        this.createUserId = in.readInt();
        this.createTime = in.readString();
        this.reportTime = in.readString();
        this.status = in.readInt();
        this.catagoryId = in.readLong();
        this.address = in.readString();
        this.isOpen = in.readInt();
        this.reviewLevel = in.readInt();
        this.isExpired = in.readInt();
        this.desc = in.readString();
        this.lng = in.readDouble();
        this.lat = in.readDouble();
        this.voiceUrl = in.readString();
        this.voiceTime = in.readInt();
        this.localImgUrl = in.readString();
        this.problemLevel = in.readInt();
        this.isAttention = in.readInt();
        this.isCreateUserAttention = in.readInt();
        this.isDraft = in.readInt();
        this.nickName = in.readString();
        this.dn = in.readString();
        this.avasterId = in.readInt();
        this.resourceList = in.createTypedArrayList(ResourceBean.CREATOR);
        this.statusChangeList = new ArrayList<StatusChangeBean>();
        in.readList(this.statusChangeList, StatusChangeBean.class.getClassLoader());
    }

    public static final Creator<ProblemBean> CREATOR = new Creator<ProblemBean>() {
        @Override
        public ProblemBean createFromParcel(Parcel source) {
            return new ProblemBean(source);
        }

        @Override
        public ProblemBean[] newArray(int size) {
            return new ProblemBean[size];
        }
    };
}
